﻿<!DOCTYPE html>
<html lang="zh">
 <head> 
  <meta charset="UTF-8" /> 
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> 
  <meta name="viewport" content="width=device-width, initial-scale=1.0" /> 
  <title>炽热教育课后作业</title> 
  <!--图标样式和布局--> 
     <link href="css/work_css1.css" rel="stylesheet" />
     <link href="css/work_css2.css" rel="stylesheet" />
     <link href="css/work_css3.css" rel="stylesheet" />
     <link href="../../css/font-awesome-4.7.0/css/font-awesome.css" rel="stylesheet" />
     <link href="../../css/font-awesome-4.7.0/css/font-awesome.min.css" rel="stylesheet" />
   <!--公共样式--> 
  <style type="text/css">

	.demo{padding: 2em 0; background: #fff;}

	a:hover,a:focus{

		text-decoration: none;

		outline: none;

	}

	#accordion .panel{

		border: none;

		box-shadow: none;

		border-radius: 0;

		margin: 0 0 15px 10px;

	}

	#accordion .panel-heading{

		padding: 0;

		border-radius: 30px;

	}

	#accordion .panel-title a{

		display: block;

		padding: 12px 20px 12px 50px;

		background: #ebb710;

		font-size: 18px;

		font-weight: 600;

		color: #fff;

		border: 1px solid transparent;

		border-radius: 30px;

		position: relative;

		transition: all 0.3s ease 0s;

	}

	#accordion .panel-title a.collapsed{

		background: #fff;

		color: #0d345d;

		border: 1px solid #ddd;

	}

	#accordion .panel-title a:after,

	#accordion .panel-title a.collapsed:after{

		content: "\f107";

		font-family: fontawesome;

		width: 55px;

		height: 55px;

		line-height: 55px;

		border-radius: 50%;

		background: #ebb710;

		font-size: 25px;

		color: #fff;

		text-align: center;

		border: 1px solid transparent;

		box-shadow: 0 3px 10px rgba(0, 0, 0, 0.58);

		position: absolute;

		top: -5px;

		left: -20px;

		transition: all 0.3s ease 0s;

	}

	#accordion .panel-title a.collapsed:after{

		content: "\f105";

		background: #fff;

		color: #0d345d;

		border: 1px solid #ddd;

		box-shadow: none;

	}

	#accordion .panel-body{

		padding: 20px 25px 10px 9px;

		background: transparent;

		font-size: 14px;

		color: #8c8c8c;

		line-height: 25px;

		border-top: none;

		position: relative;

	}

	#accordion .panel-body p{

		padding-left: 25px;

		border-left: 1px dashed #8c8c8c;

	}

</style> 
 </head> 
 <body onload ="mainManager()"> 
  <div class="demo"> 
   <div class="container"> 
    <div class="row"> 
     <div class="col-md-offset-3 col-md-6"> 
      <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"> 
      
      </div> 
     </div> 
    </div> 
   </div> 
  </div> 
     <script src="css/work_js1.js"></script>
     <script src="css/work_js2.js"></script>
     		<script src="../../backstage/lib/jquery/1.9.1/jquery.js"></script>

     <script>
         function GetQueryString(name) {
             var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
             var r = window.location.search.substr(1).match(reg); //search,查询？后面的参数，并匹配正则
             if (r != null) return unescape(r[2]);
             return null;
         }

         function mainManager() {
             var code = GetQueryString('code');
             var openid = GetQueryString('openid');
             if (openid.length > 0) {
                 getWorkList();
             } else {
                 getWechatInfo();
             }

         }

         // 1.获取微信信息
         function getWechatInfo() {
           
             var args = $.param({
                 "code": code,
                 "openid":openid
             })
             $.ajax({
                 url: '../../ChireInter/Wechat/wechat_auth.ashx',
                 data: args,
                 type: 'post',
                 dataType: 'json',
                 success: function (res) {
                     if (res.errCode == 200) {

                         getWorkList();           // 获取认证状态
                     } else {

                     }
                 },
                 error: function (err) {

                 }
             })

         }


         // 1.获取作业列表
         function getWorkList() {
             var code = GetQueryString('code');
             var openid = GetQueryString('openid');

             var args = $.param({
                 "code": code,
                 "openid": openid
             })

             $.ajax({
                 url: '../../ChireInter/Work/Work_Student_List.ashx',
                 data: args,
                 type: 'post',
                 dataType: 'json',
                 success: function (res) {
                     if (res.errCode == 200) {
                         if (res.data.list.length == 0) {
                             var searchUrl = encodeURI("../404/404.html?error=当前还没有设置作业");
                             window.location.href = searchUrl;
                         } else {
                             var html = "";

                             for (var i in res.data.list) {
                                 html += "<div class=\"panel panel-default\">";
                                 html += "<div class=\"panel-heading\" role=\"tab\" id=\"heading" + i + "\">";
                                 html += "<h4 class=\"panel-title\">";
                                 if (i == 0) {
                                     html += "<a role=\"button\" data-toggle=\"collapse\" data-parent=\"#accordion\" href=\"#collapse" + i + "\" aria-expanded=\"true\" aria-controls=\"collapse" + i + "\">";
                                 } else {
                                     html += "<a class=\"collapsed\" role=\"button\" data-toggle=\"collapse\" data-parent=\"#accordion\" href=\"#collapse" + i + "\" aria-expanded=\"false\" aria-controls=\"collapse" + i + "\">";
                                 }
                                 html += res.data.list[i].workName;
                                 html += "</a></h4></div>";
                                 if (i == 0) {
                                     html += "<div id=\"collapse" + i + "\" class=\"panel-collapse collapse in\" role=\"tabpanel\" aria-labelledby=\"heading" + i + "\" aria-expanded=\"true\">";
                                 } else {
                                     html += "<div id=\"collapse" + i + "\" class=\"panel-collapse collapse\" role=\"tabpanel\" aria-labelledby=\"heading" + i + "\" aria-expanded=\"false\">";
                                 }
                                 html += "<div class=\"panel-body\">";
                                 for (var j in res.data.list[i].workList) {
                                     html += "<p>" + res.data.list[i].workList[j] + "</p>";
                                 }

                                 html += "</div></div></div>";
                             }
                             var work_line = $('#accordion');
                             work_line.prepend(html);
                         }
                         
                     } else {
                         alert('提交失败');
                     }
                 },
                 error: function (err) {
                     alert('提交失败' + err);
                 }
             })
         }

    </script>
 </body>
</html>